<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ include file="/commons/jsp/taglibs.jsp"%>
<%@taglib uri="http://www.framework.com/taglib" prefix="frame"%>
 <HEAD>
<TITLE>weboffice演示页面</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="${ctx}/word_plugin/style.css"></link>
<script type="text/javascript" src="${ctx}/commons/js/jquery-1.8.0.min.js"></script>
<script src="${ctx}/word_plugin/main.js" type="text/javascript"></script>

<!-- --------------------=== 调用Weboffice初始化方法 ===--------------------- -->
<SCRIPT language=javascript event=NotifyCtrlReady for=WebOffice1>
	/****************************************************
	 *
	 *	在装载完Weboffice(执行<object>...</object>)
	 *	控件后执行 "WebOffice1_NotifyCtrlReady"方法
	 *
	 ****************************************************/
	WebOffice_Event_Flash("NotifyCtrlReady");
	WebOffice1_NotifyCtrlReady()
</SCRIPT>

<SCRIPT language=javascript event=NotifyWordEvent(eventname)
	for=WebOffice1>
<!--
	WebOffice_Event_Flash("NotifyWordEvent");
	WebOffice1_NotifyWordEvent(eventname);
//-->
</SCRIPT>

<SCRIPT language=javascript event=NotifyToolBarClick(iIndex)
	for=WebOffice1>
<!--
	WebOffice_Event_Flash("NotifyToolBarClick");
	WebOffice1_NotifyToolBarClick(iIndex);
//-->
</SCRIPT>

<SCRIPT language=javascript>
	/****************************************************
	 *
	 *		控件初始化WebOffice方法
	 *
	 ****************************************************/
	function WebOffice1_NotifyCtrlReady() {
		document.all.WebOffice1.SetWindowText("授权XX(可通过接口自定义)", 0);
		document.all.WebOffice1.OptionFlag |= 128;
		document.all.WebOffice1.HideMenuItem(0x01+0x02+0x10+0x20+0x4000+0x04);
		//打开文档
		var path=$("#filepath").val();
		var prefix=$("#prefix").val();
		document.all.WebOffice1.LoadOriginalFile(path, prefix);
		if(prefix=="doc"){
			var obj;
			obj = new Object(document.all.WebOffice1.GetDocumentObject());
			obj.ActiveWindow.View.ReadingLayout = 1;
		}
		
	}
	var flag = false;
	function menuOnClick(id) {
		var id = document.getElementById(id);
		var dis = id.style.display;
		if (dis != "none") {
			id.style.display = "none";

		} else {
			id.style.display = "block";
		}
	}
	/****************************************************
	 *
	 *		接收office事件处理方法
	 *
	 ****************************************************/
	var vNoCopy = 0;
	var vNoPrint = 0;
	var vNoSave = 0;
	var vClose = 0;
	function no_copy() {
		vNoCopy = 1;
	}
	function yes_copy() {
		vNoCopy = 0;
	}

	function no_print() {
		vNoPrint = 1;
	}
	function yes_print() {
		vNoPrint = 0;
	}

	function no_save() {
		vNoSave = 1;
	}
	function yes_save() {
		vNoSave = 0;
	}
	function EnableClose(flag) {
		vClose = flag;
	}
	function CloseWord() {

		document.all.WebOffice1.CloseDoc(0);
	}

	function WebOffice1_NotifyWordEvent(eventname) {
		if (eventname == "DocumentBeforeSave") {
			if (vNoSave) {
				document.all.WebOffice1.lContinue = 0;
				alert("此文档已经禁止保存");
			} else {
				document.all.WebOffice1.lContinue = 1;
			}
		} else if (eventname == "DocumentBeforePrint") {
			if (vNoPrint) {
				document.all.WebOffice1.lContinue = 0;
				alert("此文档已经禁止打印");
			} else {
				document.all.WebOffice1.lContinue = 1;
			}
		} else if (eventname == "WindowSelectionChange") {
			if (vNoCopy) {
				document.all.WebOffice1.lContinue = 0;
				//alert("此文档已经禁止复制");
			} else {
				document.all.WebOffice1.lContinue = 1;
			}
		} else if (eventname == "DocumentBeforeClose") {
			if (vClose == 0) {
				document.all.WebOffice1.lContinue = 0;
			} else {
				//alert("word");
				document.all.WebOffice1.lContinue = 1;
			}
		}
		//alert(eventname); 
	}
	function dd() {

		document.all.WebOffice1.FullScreen = 0;

	}
</SCRIPT>
<META content="MSHTML 6.00.2900.5921" name=GENERATOR>
</HEAD>
		<BODY style="BACKGROUND: #ccc" onunload="return window_onunload()">
			<CENTER>
				<DIV style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; BACKGROUND: #fff; PADDING-BOTTOM: 0px; MARGIN: -10px 0px 0px; WIDTH: 1024px; PADDING-TOP: 10px; HEIGHT: 800px" align=center>
					<FORM name=myform>
						<TABLE class=TableBlock width="90%">
							<input type="hidden" name="commandtext">
							<input type="hidden" id="filepath" name="filepath" value="http://192.168.4.16:8080/${ctx }/${filepath}">
							<input type="hidden" id="prefix" name="prefix" value="${prefix}">
							<TBODY>
								<TR>
									<TD class=TableData vAlign=top width="100%">
										<!-- -----------------------------== 装载weboffice控件 ==--------------------------------- -->
									 <!-- ---	<SCRIPT src="LoadWebOffice.js"></SCRIPT>-----------------------------== 结束装载控件 ==----------------------------------- -->
										<object id=WebOffice1 height=768 width='100%' style='LEFT: 0px; TOP: 0px'
										 classid='clsid:E77E049B-23FC-4DB8-B756-60529A35FAD5' codebase='${ctx }/word_plugin/WebOffice.cab#Version=7,0,1,0'>"
											<param name='_ExtentX' value='6350'>
											<param name='_ExtentY' value='6350'>"
										</OBJECT>
									</TD>
								</TR>
							</TBODY>
						</TABLE>
					</FORM>
				</DIV>
			</CENTER>
		</BODY>
</html>
